package com.firefly.netty.demo;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @author King
 * @date 2021/7/14
 */
public class DataFrameEncoder extends MessageToByteEncoder<DataFrame> {

    @Override
    protected void encode(ChannelHandlerContext ctx, DataFrame msg, ByteBuf out) throws Exception {
        System.out.println("encode-------------------------");
        System.out.println(msg);
        // 写出帧头
        out.writeBytes(msg.toString().getBytes());
    }
}